/**
 * @author: 野狼上校
 * @create: 2024-03-28 15:49
 * @version: 1.0
 *
 *  用户相关的请求
 */
import instance, {RespResult} from "@/api/index.ts"

/*手机号码登录*/
export const loginInfo = (data: any): Promise<RespResult> => {
    return instance({
        url: "/auth/login",
        method: "POST",
        data: data
    })
}

/*分页查询用户数据*/
export const getUsersByPage = (data: any): Promise<RespResult> => {
    return instance({
        url: `/auth/user/getUsersByPage`,
        method: "get",
        params: data
    })
}

/*根据Id查询用户数据*/
export const getUsersById = (id: number): Promise<RespResult> => {
    return instance({
        url: `/auth/user/getUserById/${id}`,
        method: "get"
    })
}


/*根据Id删除用户*/
export const deleteUserById = (id: number): Promise<RespResult> => {
    return instance({
        url: `/auth/user/deleteById/${id}`,
        method: "delete"
    })
}

/*新增用户*/
export const addUser = (data: any): Promise<RespResult> => {
    return instance({
        url: `/auth/user/insert`,
        method: "post",
        data: data
    })
}

/*修改用户*/
export const editUser = (data: any): Promise<RespResult> => {
    return instance({
        url: `/auth/user/update`,
        method: "put",
        data: data
    })
}

/* 单个属性更新 */
export const patchUser = (data: any): Promise<RespResult> => {
    return instance({
        url: `/auth/user/patch`,
        method: "get",
        params: data
    })
}

/* 设置角色 */
export const setRolesForUser = (data:any): Promise<RespResult> => {
    return instance({
        url: `/auth/user/setRolesForUser`,
        method: "get",
        params: data
    })
}